package com.fairytask.ui.item.activeItem
{
	import com.fairytask.data.BaseData;
	import com.fairytask.engine.components.BaseComponent;
	import com.fairytask.engine.components.table.TableEvent;
	import com.fairytask.engine.components.table.TableItem;
	import com.fairytask.engine.components.table.TableRow;
	
	import flash.events.MouseEvent;
	
	/**
	 * 活跃度单行数据 
	 * @author xujh
	 * 
	 */
	public class ActiveTableRow extends TableRow
	{
		private var _pos			:int;
		private var _itemArr		:Array	=	[];
		private var _data			:BaseData;
		//父节点
		private var _pNote		:int;
		
		public function ActiveTableRow()
		{
			this.addEventListener(MouseEvent.MOUSE_OVER,onOver);
			this.addEventListener(MouseEvent.MOUSE_OUT,onOut);
		}
		
		private function onOver(evt:MouseEvent):void
		{
			dispatchEvent(new TableEvent(TableEvent.ROW_OVER,pos,data));
		}
		
		private function onOut(evt:MouseEvent):void
		{
			dispatchEvent(new TableEvent(TableEvent.ROW_OUT,pos,data));
		}
		
		/**
		 * 添加子项 
		 * @param item
		 * 
		 */
		public function addTableItem(item:BaseComponent):void
		{
			if(item is TableItem)
			{
				addItem(item as TableItem);
			}
			else
			{
				addOtherItem(item);
			}
		}
		
		/**
		 * 添加其他对象 
		 * @param item
		 * 
		 */
		private function addOtherItem(item:BaseComponent):void
		{
			_itemArr.push(item);
			item.x	=	_itemPox+ActiveTable.colSplit;
			item.y	=	-3;
			addChild(item);
			_itemPox	+= item.width;
			
			drawBg();
		}
		
		/**
		 * 一切为了点击 
		 */
		private function drawBg():void
		{
			this.graphics.clear();
			this.graphics.beginFill(0,0);
			this.graphics.drawRect(0,0,_itemPox,this.height);
			this.graphics.endFill();
		}
		
		public function get pNote():int
		{
			return _pNote;
		}
		
		public function set pNote(value:int):void
		{
			_pNote = value;
		}
	}
}